﻿using EmoneyWeiXinCommon;
using EmoneyWeiXinEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EmoneyWeiXinBLL
{
    public class GPYSBLL
    {
        /// <summary>
        /// 统一分数表（各项分数及综合评级、一句话描述）
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <returns></returns>
        public string Getsdstockscoreex(string code)
        {
            string key = "sdstockscoreex" + code;
            string[] serverlist = Config.MemServer.Split(',');
            BeIT.MemCached.MemcachedClient.Setup("EMoney.WeiXin.BLL.GPYSBLL.Getsdstockscoreex", serverlist);
            BeIT.MemCached.MemcachedClient cache = BeIT.MemCached.MemcachedClient.GetInstance("EMoney.WeiXin.BLL.GPYSBLL.Getsdstockscoreex");
            cache.SendReceiveTimeout = 5000;
            cache.MinPoolSize = 1;
            cache.MaxPoolSize = 5;
            byte[] btGet = cache.Get(key) as byte[];
            string str1 = "";
            if (btGet != null)
                str1 = System.Text.Encoding.UTF8.GetString(btGet);
            if (string.IsNullOrEmpty(str1))
                return "";
            return str1;
        }

        /// <summary>
        /// 体检综述
        /// </summary>
        /// <param name="code">股票代码</param>
        /// <returns></returns>
        public List<Pgfirst_yEntity> Getpgfirst_y(string code)
        {
            string key = "pgfirst_y" + code;
            string[] serverlist = Config.MemServer.Split(',');
            BeIT.MemCached.MemcachedClient.Setup("EMoney.WeiXin.BLL.GPYSBLL.Getpgfirst_y", serverlist);
            BeIT.MemCached.MemcachedClient cache = BeIT.MemCached.MemcachedClient.GetInstance("EMoney.WeiXin.BLL.GPYSBLL.Getpgfirst_y");
            cache.SendReceiveTimeout = 5000;
            cache.MinPoolSize = 1;
            cache.MaxPoolSize = 5;
            byte[] btGet = cache.Get(key) as byte[];
            string str1 = "";
            if (btGet != null)
                str1 = System.Text.Encoding.UTF8.GetString(btGet);
            List<Pgfirst_yEntity> lsts;

            if (string.IsNullOrEmpty(str1))
                return new List<Pgfirst_yEntity>();
            lsts = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Pgfirst_yEntity>>("[" + str1 + "]");

            return lsts;
        }
    }
}
